package zhaoq_hero.superapp.providers;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.provider.ContactsContract;

/**
 * ProjectName : zhaoq_hero.superapp.database
 * Created by : zhaoQiang
 * Email : zhaoq_hero163.com
 * On 2015/10/31 // 09:57
 */
public class DBHelper extends SQLiteOpenHelper{

    private static final String DB_NAME = "app.db";

    private static final int DE_VER = 2;

    private static final String CREATE_TABLE_HISTORY =
            "create table "
               + DataContract.TABLE_HISTORY
               + "("
               + DataContract.History._ID + " integer primary key autoincrement,"
               + DataContract.History.URL + " text not null," +
                 DataContract.History.TITLE + " text, " +
                 DataContract.History.TIME + " text "
               + ")" ;

    public static final String CREATE_TABLE_BOOK =
            "create table " +
                    DataContract.TABLE_BOOK +
                    "(" +
                    DataContract.History._ID + " integer primary key autoincrement," +
                    DataContract.History.URL + " text not null," +
                    DataContract.History.TITLE + " text "+
                    ");";

    public DBHelper(Context context){
        super(context,DB_NAME,null,DE_VER);
    }

    /**
     * 第一次被创建时  会调用该方法：
     * @param db
     */
    @Override
    public void onCreate(SQLiteDatabase db) {

        db.execSQL(CREATE_TABLE_HISTORY);
        db.execSQL(CREATE_TABLE_BOOK);

    }

    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {

    }
}
